﻿<UserControl x:Class="UML_Creator.View.InterfaceDiagram"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             xmlns:u="clr-namespace:UML_Creator.ViewModel"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <Canvas>
        <Grid Canvas.Top="{Binding Y}" Canvas.Left="{Binding X}" 
              u:SizeObserver.Observe="True"
             u:SizeObserver.ObservedWidth="{Binding Width, Mode=OneWayToSource}"
             u:SizeObserver.ObservedHeight="{Binding Height, Mode=OneWayToSource}">
            
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>

            <TextBox Grid.Column="0" Grid.Row="0" TextWrapping="Wrap" Text="{Binding InterfaceName}" IsInactiveSelectionHighlightEnabled="True" IsManipulationEnabled="True" BorderThickness="1,1,1,0" Foreground="Black" FontWeight="Bold" IsEnabled="False" BorderBrush="{Binding Colour}" Opacity="{Binding Opacity}" />
            <TextBox Grid.Column="0" Grid.Row="1" TextWrapping="Wrap" Text="{Binding InterfaceMethods}" IsEnabled="False" BorderThickness="1,1,1,1" Foreground="Black" BorderBrush="{Binding Colour}" Opacity="{Binding Opacity}" />
        </Grid>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDoubleClick">
                <cmd:EventToCommand Command="{Binding DataContext.MouseDoubleClickNodeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
            <i:EventTrigger EventName="MouseDown">
                <cmd:EventToCommand Command="{Binding DataContext.MouseDownNodeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
            <i:EventTrigger EventName="MouseMove">
                <cmd:EventToCommand Command="{Binding DataContext.MouseMoveNodeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
            <i:EventTrigger EventName="MouseUp">
                <cmd:EventToCommand Command="{Binding DataContext.MouseUpNodeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </Canvas>
</UserControl>
